import Cookies from 'js-cookie'

const state = {
  loading: false,
  sidebar: {
    opened: true,
    withoutAnimation: false,
  },
  device: 'desktop',
  tabActive: -1,
  menuList: [
    {
      id: 0,
      title: '首页111',
      path: '/',
      children: [
        {
          path: 'dashboard',
          name: 'Index',
          title: '首页',
          affix: 'True',
          buttons: [],
        },
      ],
    },
    {
      id: 1,
      title: '数据分析',
      path: '/dataAnalysis',
      children: [
        {
          path: '/feijiuData',
          redirect: '',
          title: 'Feijiu数据',
          children: [
            {
              path: 'assetData',
              name: 'assetData',
              title: '资产数据',
              buttons: [''],
            },
            {
              path: 'aloneData',
              name: 'aloneData',
              title: '独享数据',
              buttons: ['detail'],
            },
            {
              path: 'noticeData',
              name: 'noticeData',
              title: '拍卖数据',
              buttons: [],
            },
          ],
        },
        {
          path: '/industryData',
          redirect: '',
          title: '行业数据',
          children: [
            {
              path: 'industryAsset',
              name: 'industryAsset',
              title: '行业资产',
              buttons: [''],
            },
            {
              path: 'industryNotice',
              name: 'industryNotice',
              title: '行业拍卖',
              buttons: ['detail'],
            },
          ],
        },
        {
          path: '/usersNumber',
          redirect: '',
          title: '用户量',
          children: [
            {
              path: 'usersNumber',
              name: 'usersNumber',
              title: '用户量',
              buttons: [''],
            },
          ],
        },
        {
          path: '/businessPush',
          redirect: '',
          title: '生意推送',
          children: [
            {
              path: 'assetsPush',
              name: 'assetsPush',
              title: '资产推送',
              buttons: [''],
            },
            {
              path: 'alonePush',
              name: 'alonePush',
              title: '独享推送',
              buttons: [''],
            },
            {
              path: 'noticePush',
              name: 'noticePush',
              title: '拍卖推送',
              buttons: [''],
            },
          ],
        },
        {
          path: '/userProfile',
          redirect: '',
          title: '用户画像',
          children: [
            {
              path: 'groupProfile',
              name: 'groupProfile',
              title: '群体画像',
              buttons: [''],
            },
            {
              path: 'personProfile',
              name: 'personProfile',
              title: '个人画像',
              buttons: [''],
            },
            {
              path: 'labelManagement',
              name: 'labelManagement',
              title: '标签管理',
              buttons: [''],
            },
          ],
        },
      ],
    },
    {
      id: 2,
      title: '会员管理',
      path: '/memberManagement',
      children: [],
    },
    {
      id: 3,
      title: '信息管理',
      path: '/infoManagement',
      children: [
        {
          path: '/assetsPublic',
          redirect: '',
          title: '资产(公开)',
          children: [
            {
              path: 'assetBoard',
              name: 'assetBoard',
              title: '资产看板',
              buttons: [''],
            },
            {
              path: 'assetManagement',
              name: 'assetManagement',
              title: '资产管理',
              buttons: ['detail'],
            },
            {
              path: 'assetPublish',
              name: 'assetPublish',
              title: '发布',
              buttons: [],
            },
            {
              path: 'lockRecord',
              name: 'lockRecord',
              title: '锁定记录',
              buttons: [],
            },
            {
              path: 'assetsCompetitorStatistics',
              name: 'assetsCompetitorStatistics',
              title: '竞品对比统计',
              buttons: ['detail'],
            },
            {
              path: 'assetsCompetitorManagement',
              name: 'assetsCompetitorManagement',
              title: '竞品对比处理',
              buttons: ['detail'],
            },
          ],
        },
        {
          path: '/assetsAlone',
          redirect: '',
          title: '资产(独享)',
          children: [
            {
              path: 'aloneBoard',
              name: 'aloneBoard',
              title: '独享看板',
              buttons: [''],
            },
            {
              path: 'aloneManagement',
              name: 'aloneManagement',
              title: '独享管理',
              buttons: ['detail'],
            },
            {
              path: 'alonePublish',
              name: 'alonePublish',
              title: '发布',
              buttons: [],
            },
            // {
            //   path: 'AIClue',
            //   name: 'AIClue',
            //    title: 'AI外呼线索' ,
            //   buttons: [],
            // },
          ],
        },
        {
          path: '/biddingNotice',
          redirect: '',
          title: '招标公告',
          children: [
            {
              path: 'noticeBoard',
              name: 'noticeBoard',
              title: '公告看板',
              buttons: [''],
            },
            {
              path: 'noticeManagement',
              name: 'noticeManagement',
              title: '公告管理',
              buttons: ['detail'],
            },
            {
              path: 'noticePublish',
              name: 'noticePublish',
              title: '公告添加',
              buttons: ['detail'],
            },
            {
              path: 'innerNoticeManagement',
              name: 'innerNoticeManagement',
              title: '内部公告管理',
              buttons: ['detail'],
            },
            {
              path: 'noticeStatistics',
              name: 'noticeStatistics',
              title: '公告统计',
              buttons: ['detail'],
            },
            {
              path: 'innerNoticeStatistics',
              name: 'innerNoticeStatistics',
              title: '内部公告统计',
              buttons: ['detail'],
            },
            {
              path: 'competitorStatistics',
              name: 'competitorStatistics',
              title: '竞品对比统计',
              buttons: ['detail'],
            },
            {
              path: 'competitorManagement',
              name: 'competitorManagement',
              title: '竞品对比处理',
              buttons: ['detail'],
            },
          ],
        },
      ],
    },
    {
      id: 4,
      title: '系统管理',
      path: '/systemManagement',
      children: [
        {
          path: '/system',
          redirect: '',
          title: '系统管理',
          children: [
            {
              path: 'department',
              name: 'department',
              title: '部门管理',
              buttons: [],
            },
            {
              path: 'role',
              name: 'role',
              title: '角色管理',
              buttons: ['detail'],
            },
            {
              path: 'account',
              name: 'account',
              title: '员工管理',
              buttons: [''],
            },
            {
              path: 'menu',
              name: 'menu',
              title: '菜单管理',
              buttons: [],
            },
          ],
        },
      ],
    },
    {
      id: 5,
      title: 'CRM',
      path: '/CRM',
      children: [],
    },
  ],
}

const mutations = {
  TOGGLE_SIDEBAR: (state) => {
    state.sidebar.opened = !state.sidebar.opened
    state.sidebar.withoutAnimation = false
    if (state.sidebar.opened) {
      Cookies.set('sidebarStatus', 1)
    } else {
      Cookies.set('sidebarStatus', 0)
    }
  },
  CLOSE_SIDEBAR: (state, withoutAnimation) => {
    Cookies.set('sidebarStatus', 0)
    state.sidebar.opened = false
    state.sidebar.withoutAnimation = withoutAnimation
  },
  TOGGLE_DEVICE: (state, device) => {
    state.device = device
  },
  SET_TAB_ACTIVE: (state, id) => {
    state.tabActive = id
  },
  showLoading: (state) => {
    state.loading = true
  },
  hideLoading: (state) => {
    state.loading = false
  },
}

const actions = {
  toggleSideBar({ commit }) {
    commit('TOGGLE_SIDEBAR')
  },
  closeSideBar({ commit }, { withoutAnimation }) {
    commit('CLOSE_SIDEBAR', withoutAnimation)
  },
  toggleDevice({ commit }, device) {
    commit('TOGGLE_DEVICE', device)
  },
  setTabActive({ commit }, id) {
    commit('SET_TAB_ACTIVE', id)
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
